<%-- 
    Document   : courier
    Created on : 2018-5-27, 21:00:55
    Author     : Dannis
--%>

<%@page import="com.antexpress.common.Const"%>
<%@page import="com.antexpress.pojo.Employee"%>
<%@page import="com.antexpress.bean.Authentication"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Express -- Ant Express</title>
        <link rel="shortcut icon" href="static/img/ant-logo.png">
        <link href="static/css/style.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/normalize.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/default.css" rel="stylesheet" type="text/css"/>
        <link href="static/dist/css/jquery.secretnav.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/demo.css" rel="stylesheet" type="text/css"/>
        <link href="static/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/edbox.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/selectpage.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/stickysort.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
        <%
            if (!Authentication.isLogin(session)) {
                response.sendRedirect("index.jsp");
                return;
            }
            Employee emp = (Employee) session.getAttribute(Const.CURRENT_USER);
            if (!Authentication.isHRAdmin(emp) && !Authentication.isExpressAdmin(emp)
                    && !Authentication.isExpressCourier(emp) && !Authentication.isExpressAreaManager(emp)
                    && !Authentication.isExpressLogisticsApproval(emp) && !Authentication.isExpressLogisticsManager(emp)) {
                response.sendRedirect("404.jsp");
                return;
            }
        %>
        <div class="sn-outer-wrapper sn-moveleft modalview">
            <div class="sn-content-wrapper transform" style="cursor: default;">
                <div id="content" style="top: 0px;">
                    <jsp:include page="ui/header.jsp"/>
                    <div class="container-nav">
                        <div class="container">
                            <button class="open btn btn-default bt-open" title="Menu"><i class="fa fa-bars" aria-hidden="true"></i></button>
                            <!--此处可以扩展其他的功能-->
                            <%
                                if (Authentication.isExpressLogisticsManager(emp)) {
                                    out.println("<a href='express_courier.jsp' class='content-nav-bt'>Courier Management</a>");
                                    out.println("<a href='express_area_manager.jsp' class='content-nav-bt'>Area Manager Management</a>");
                                    out.println("<a href='express_logistics_approval.jsp' class='content-nav-bt'>Logistics Approval Management</a>");

                                }
                            %>
                        </div>
                    </div>
                    <div class="container" style="text-align: left;color: #000">
                        <h1 class="heading"><i class="fa fa-book" aria-hidden="true"></i> Express Management</h1>
                        <div class="content-div">
                            <h4 class="subheading"><i class="fa fa-chevron-right" aria-hidden="true"></i>Search Bill Information</h4>
                            <div>
                                <form onsubmit="return false;">
                                    <div style="width:700px; display:inline-block">
                                        <table class="form-table" style="margin-bottom: 0px;">
                                            <tr>
                                                <td>Weight</td>
                                                <td><input type="number" min="0" id="selectPageStartWeight" placeholder="Min Weight" style="width: 160px;"/> to <input type="number" min="0" id="selectPageEndWeight" placeholder="Max Weight" style="width: 160px;"/></td>
                                            </tr>
                                            <tr>
                                                <td>MinFreight</td>
                                                <td><input type="number" min="0" id="selectPageStartFreight" placeholder="Min Freight" style="width: 160px;"/> to <input type="number" min="0" id="selectPageEndFreight" placeholder="Min Freight" style="width: 160px;"/></td>
                                            </tr>
<!--                                            <tr id="sendProCity" style="display: none">
                                                <td>From</td>
                                                <td><input type="text" id="selectStartPageProvince" placeholder="Province" style="width: 172px"/><input type="text" id="selectStartPageCity" placeholder="City" style="width: 172px"/></td>
                                            </tr>
                                            <tr id="recProCity" style="display: none">
                                                <td>To</td>
                                                <td><input type="text" id="selectEndPageProvince" placeholder="Province" style="width: 172px"/><input type="text" id="selectEndPageCity" placeholder="City" style="width: 172px"/></td>
                                            </tr>-->
                                            <tr>
                                                <td>CreateTime</td>
                                                <td><input type="date" name="startcreatetime" id="selectStartPageCreateTime" style="width: 160px;"/> to <input type="date" name="endcreatetime" id="selectEndPageCreateTime" style="width: 160px;"/></td>
                                            </tr>
                                            <tr>
                                                <td>UpdateTime</td>
                                                <td><input type="date" name="startupdatetime" id="selectStartPageUpdateTime" style="width: 160px"/> to <input type="date" name="endupdatetime" id="selectEndPageUpdateTime" style="width: 160px"/></td>
                                            </tr>
                                            <tr>
                                                <td>Status</td>
                                                <td colspan="3"><input type="text" id="selectPageStatus" placeholder="Please select status" style="width: 345px;"/></td>
                                            </tr>
                                        </table>
                                    </div>
                                    <div class="content-center" style="margin-top:0px;">
                                        <input id="bt-clickToWorkingSheet" onclick="search_bills()" type="submit" class="btn btn-primary" value="Search" style="margin-left: 20px;"/>
                                    </div>
                                </form>
                            </div>
                            <br/>
                            <div id="page-table-content" style="display: none;">
                                <table id="page-table" class="pub-table pub-table-hover">
                                    <thead>
                                        <tr>
                                            <th>&nbsp;<i class="fa fa-check-square-o" aria-hidden="true"></i>&nbsp;</th>
                                            <th>Consignor</th>
                                            <th>City</th>
                                            <th>Consignee</th>
                                            <th>City</th>
                                            <th>CreateTime</th>
                                            <th>UpdateTime</th>
                                            <th>&nbsp;<i class="fa fa-pencil-square-o" aria-hidden="true"></i>&nbsp;</th>
                                        </tr>
                                    </thead>
                                    <tbody id="bill-table-body">
                                    </tbody>

                                </table>
                                <div id="searchResultMsg" class="content-center table-result-msg">

                                </div>
                            </div>
                            <!--详细信息模态框-->
                            <div id="bill-show-box" class="ed-div" style="display:none;">
                                <h3 class="subheading" style="margin: 3px;"><i class="fa fa-info-circle" aria-hidden="true"></i> Bill Details</h3><br/>
                                <table class="model-form-table" style="color: black;">
                                    <tr style="display: none">
                                        <td>BillID</td>
                                        <td id="bill-show-BillID"></td>
                                    </tr>
                                    <tr>
                                        <td>ConsignorName</td>
                                        <td id="bill-show-ConsignorName"></td>
                                    </tr>
                                    <tr>
                                        <td>ConsignorCity</td>
                                        <td id="bill-show-ConsignorCity"></td>
                                    </tr>
                                    <tr>
                                        <td>ConsigneeName</td>
                                        <td id="bill-show-ConsigneeName"></td>
                                    </tr>
                                    <tr>
                                        <td>ConsigneeCity</td>
                                        <td id="bill-show-ConsigneeCity"></td>
                                    </tr>
                                    <tr>
                                        <td>Weight</td>
                                        <td id="bill-show-Weight"></td>
                                    </tr>
                                    <tr>
                                        <td>Amount</td>
                                        <td id="bill-show-Amount"></td>
                                    </tr>
                                    <tr>
                                        <td>Freight</td>
                                        <td id="bill-show-Freight"></td>
                                    </tr>
                                    <tr>
                                        <td>PayWay</td>
                                        <td id="bill-show-PayWay"></td>
                                    </tr>
                                    <tr>
                                        <td>Insurance</td>
                                        <td id="bill-show-Insurance"></td>
                                    </tr>
                                    <tr>
                                        <td>CreateTime</td>
                                        <td id="bill-show-CreateTime"></td>
                                    </tr>
                                    <tr>
                                        <td>UpdateTime</td>
                                        <td id="bill-show-UpdateTime"></td>
                                    </tr>
                                    <tr>
                                        <td>Commits</td>
                                        <td id="bill-show-Commits"></td>
                                    </tr>
                                </table>
                                <input type="button" id="bt-add-emp-cancel" onclick="passbill()" class="btn btn-default" value="Finish"/>
                                <input type="button" id="bt-add-emp-cancel" onclick="$.edbox('close');" class="btn btn-default" value="Close"/>
                            </div><!-- 展示订单信息模态框 结束 -->
                            <div id="bill-edit-box" class="ed-div" style="display:none;"><!-- 修改Bill的模态框 -->
                                <h3 class="subheading" style="margin: 3px;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit Bills</h3><br/>
                                <form onsubmit="return false;" id="editEmpForm">
                                    <h4 class="subTitle" style="float: left;margin: 10px;"><i class="fa fa-paw" aria-hidden="true"></i> Bill Info</h4>
                                    <table class="model-form-table" style="color: black;">
                                        <tr>

                                            <td>BillID</td>
                                            <td id="bill-change-BillID"></td>
                                        </tr>
                                        <tr>
                                            <td>Weight</td>
                                            <td><input type="text" name="title" id="bill-change-Weight" style="width: 100px;">KG</td>
                                        </tr>
                                        <tr>
                                            <td>Freight</td>
                                            <td><input type="text" name="title" id="bill-change-Freight" style="width: 100px;">$</td>
                                        </tr>
                                        <tr>
                                            <td>Amount</td>
                                            <td><input type="text" name="mobile" id="bill-change-Amount" style="width: 100px;">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>PayWay</td>
                                            <td id="bill-change-PayWay"></td>
                                        </tr>
                                        <tr>
                                            <td>Insurance</td>
                                            <td><input type="text" name="add-birth" id="bill-change-Insurance" style="width: 100px;">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Status</td>
                                            <td id="bill-change-Stuatus"></td>
                                        </tr>
                                        <tr>
                                            <td>ConsignorName</td>
                                            <td><input type="text" name="add-birth" id="bill-change-ConsignorName" style="width: 100px;"></td>
                                        </tr>
                                        <tr>
                                            <td>ConsignorCity</td>
                                            <td><input type="text" name="add-birth" id="bill-change-ConsignorCity" style="width: 100px;"></td>
                                        </tr>
                                        <tr>
                                            <td>ConsigneeName</td>
                                            <td><input type="text" name="add-birth" id="bill-change-ConsigneeName" style="width: 100px;"></td>
                                        </tr>
                                        <tr>
                                            <td>ConsigneeCity</td>
                                            <td><input type="text" name="add-birth" id="bill-change-ConsigneeCity" style="width: 100px;"></td>
                                        </tr>
                                        <tr>
                                            <td>CreateTime</td>
                                            <td id="bill-change-CreateTime"></td>
                                        </tr>
                                        <tr>
                                            <td>UpdateTime</td>
                                            <td id="bill-change-UpdateTime"></td>
                                        </tr>
                                        <tr>
                                            <td>Commits</td>
                                            <td id="bill-change-Commits"></td>
                                        </tr>
                                    </table>

                                    <div class="content-center" style="margin: 10px;">
                                        <input type="submit" onclick="editNewBill()" class="btn btn-primary" value=" Save "/>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <input type="button" id="bt-edit-emp-cancel" onclick="$.edbox('close');" class="btn btn-default" value="Cancel"/>
                                    </div>
                                </form>
                            </div><!-- 修改Bill的模态框 结束 -->
                            <div id="bill-delete-box" class="ed-div" style="display:none;"><!-- 删除Bill的模态框 -->
                                <h3 class="subheading" style="margin: 3px;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Delete Bill</h3><br/>
                                <form onsubmit="return false;" id="editEmpForm">
                                    <table class="model-form-table" style="color: black;">
                                        <tr>
                                            <td>Are you sure to delete Bills? ID:</td>
                                            <td id="bill-delete-BillID"></td>
                                        </tr>
                                    </table>
                                    <div class="content-center" style="margin: 10px;">
                                        <input type="submit" onclick="deleteBill()" class="btn btn-primary" value=" Yes "/>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <input type="button" id="bt-edit-emp-cancel" onclick="$.edbox('close');" class="btn btn-default" value="Cancel"/>
                                    </div>
                                </form>
                            </div><!-- 删除Bill的模态框 结束 -->
                        </div>
                    </div>
                </div>
            </div>
            <div class="sn-nav-wrapper">
                <nav id="nav" class="sn-nav left vertical">
                    <jsp:include page="ui/nav.jsp"/>
                </nav>
            </div>
        </div>
        <script src="static/js/modernizr.custom.25376.js" type="text/javascript"></script>
        <script src="static/js/jquery.js" type="text/javascript"></script>
        <script src="static/js/common-script.js" type="text/javascript"></script>
        <script src="static/dist/js/jquery.secretnav.js" type="text/javascript"></script>
        <script src="static/js/jquery.ba-throttle-debounce.min.js" type="text/javascript"></script>
        <script src="static/js/jquery.edbox.js" type="text/javascript"></script>
        <script src="static/js/selectpage.js" type="text/javascript"></script>
        <script src="static/js/jquery.stickysort.js" type="text/javascript"></script>
        <script src="static/js/jqPaginator.js" type="text/javascript"></script>
        <script>
                                            var bill_select_data_province = {};//获得省信息
                                            var bill_select_data_start_city = {};//获得start市信息
                                            var searched_bills_info = {};//获得查询到的BillInfo

                                            $(function () {
                                                menu();
                                                $("#page-table").stickySort();
                                                getEmployeeAuthen();
                                                init_city();
                                                list_bills_selector_province();
                                            });
                                            //为管理员初始化组件
                                            function initComponentForadmin() {
                                                $("#sendProCity").css("display", "table-row");
                                                $("#recProCity").css("display", "table-row");
                                            }
                                            //判断这个Employee的权限
                                            function getEmployeeAuthen() {
                                                $.ajax({
                                                    url: "${pageContext.request.contextPath}/express/employeeAuthentication.do",
                                                    type: "POST",
                                                    dataType: "json",
                                                    success: function (result) {
                                                        if (result.status === 1) {
                                                            var authentication = result.data;
                                                            if (authentication === "yes") {
                                                                initComponentForadmin();
                                                            }
                                                        } else {
                                                            alert(result.msg);
                                                        }
                                                    },
                                                    error: function () {
//                                                                alert("Got failed");
                                                    }
                                                });
                                            }
                                            //查询Bills
                                            function search_bills() {
                                                if ($("#selectPageStartWeight").val() === "" && $("#selectPageEndWeight").val() === "" && $("#selectPageStartFreight").val() === ""
                                                        && $("#selectPageEndFreight").val() === "" && $("#selectPageStatus").val() === ""
                                                        && $("#selectStartPageCreateTime").val() === "" && $("#selectEndPageCreateTime").val() === "" && $("#selectStartPageUpdateTime").val() === ""
                                                        && $("#selectEndPageUpdateTime").val() === "") {
                                                    $.edbox({danger: "You need to choose one Condition!!"});
                                                    return;
                                                }
                                                if ($("#selectPageStartWeight").val() === "") {
                                                    $.edbox({danger: "You need to enter one Start Weight!!"});
                                                    return;
                                                }
                                                if ($("#selectPageEndWeight").val() === "") {
                                                    $.edbox({danger: "You need to enter one End Weight!!"});
                                                    return;
                                                }
                                                if ($("#selectPageStartFreight").val() === "") {
                                                    $.edbox({danger: "You need to enter one Start Freight!!"});
                                                    return;
                                                }
                                                if ($("#selectPageEndFreight").val() === "") {
                                                    $.edbox({danger: "You need to enter one End Freight!!"});
                                                    return;
                                                }
                                                if ($("#selectPageStatus").val() === "") {
                                                    $.edbox({danger: "You need to choose Status!!"});
                                                    return;
                                                }
                                                if ($("#selectStartPageCreateTime").val() === "") {
                                                    $.edbox({danger: "You need to choose Start Creat Time!!"});
                                                    return;
                                                }
                                                if ($("#selectEndPageCreateTime").val() === "") {
                                                    $.edbox({danger: "You need to choose End Creat Time!!"});
                                                    return;
                                                }
                                                if ($("#selectStartPageUpdateTime").val() === "") {
                                                    $.edbox({danger: "You need to choose  Start UpdateTime!!"});
                                                    return;
                                                }
                                                if ($("#selectEndPageUpdateTime").val() === "") {
                                                    $.edbox({danger: "You need to choose  End UpdateTime!!"});
                                                    return;
                                                }
                                                $("#searchResultMsg").empty();
                                                $.ajax({
                                                    url: "${pageContext.request.contextPath}/express/select_list_working_bills.do",
                                                    data: {//前端向后端发送数据，下面绿色的参数就是在方法里面的参数，注意名字要一致
                                                        "startweight": $("#selectPageStartWeight").val(),
                                                        "endweight": $("#selectPageEndWeight").val(),
                                                        "startfreight": $("#selectPageStartFreight").val(),
                                                        "endfreight": $("#selectPageEndFreight").val(),
                                                        "status": $("#selectPageStatus").val(),
                                                        "startprovince": $("#selectStartPageProvince").val(),
                                                        "endprovince": $("#selectEndPageProvince").val(),
                                                        "startcity": $("#selectStartPageCity").val(),
                                                        "endcity": $("#selectEndPageCity").val(),
                                                        "startcreatetime": $("input[name='startcreatetime']").val(),
                                                        "endcreatetime": $("input[name='endcreatetime']").val(),
                                                        "startupdatetime": $("input[name='startupdatetime']").val(),
                                                        "endupdatetime": $("input[name='endupdatetime']").val()
                                                    },
                                                    type: "POST",
                                                    dataType: "json",
                                                    success: function (result) {//后端向前端发送result对象，完成异步的操作，result此处为json格式，可以进行解析
                                                        if (result.status === 1) {
                                                            $("#page-table-content").css("display", "block");
                                                            var searched_bills_info = result.data;
                                                            if (searched_bills_info.length === 0) {
                                                                $("#searchResultMsg").append("No Record!!");
                                                            } else {
                                                                listBillDetails(searched_bills_info);
                                                            }
                                                            getEmployeeAuthen();
                                                        } else {
                                                            $.edbox({danger: result.msg});

                                                        }
                                                    },
                                                    error: function () {
                                                        $.edbox({danger: 'Search failed!'});
                                                    }
                                                });
                                            }
                                            function listBillDetails(billList) {
                                                $("#bill-table-body").empty();
                                                var rowNum = 0;
                                                $.each(billList, function () {
                                                    rowNum++;
                                                    var billCheckbox = $("<td>").append("<input type='checkbox'/>");
                                                    var consignor = $("<td>").append(this.consignorInfo.name);
                                                    var consignor_city = $("<td>").append(this.consignorInfo.mapTown.mapDistrict.mapCity.name);
                                                    var consignee = $("<td>").append(this.consigneeInfo.name);
                                                    var consignee_city = $("<td>").append(this.consigneeInfo.mapTown.mapDistrict.mapCity.name);
                                                    var billcreatetime = $("<td>").append(new Date(this.createtime).toString().substring(-1, 15));
                                                    var billupdatetime = $("<td>").append(new Date(this.updatetime).toString().substring(-1, 15));
                                                    var showBillOp = $("<a href='#' title='Details' edbox data-box-target='#bill-show-box' billID='" + this.id + "' consignorname='" + this.consignorInfo.name + "' consignorcity='" + this.consignorInfo.mapTown.mapDistrict.mapCity.name
                                                            + "' consigneename='" + this.consigneeInfo.name + "' consigneecity='" + this.consigneeInfo.mapTown.mapDistrict.mapCity.name + "' freight='" + this.freight + "' insured='" + this.insured + "' payway='" + this.panment
                                                            + "' weight='" + this.weight + "' commit='" + this.commit + "' amount='" + this.amount + "' billcreatetime='" + this.createtime + "' billupdatetime='" + this.updatetime + "'></a>")
                                                            .append("<i class='fa fa-pencil-square-o' aria-hidden='true'></i>");
                                                    showBillOp.click(function () {
                                                        $("#bill-show-BillID").empty();
                                                        $("#bill-show-BillID").append(showBillOp.attr("billID"));
                                                        $("#bill-show-ConsignorName").empty();
                                                        $("#bill-show-ConsignorName").append(showBillOp.attr("consignorname"));
                                                        $("#bill-show-ConsignorCity").empty();
                                                        $("#bill-show-ConsignorCity").append(showBillOp.attr("consignorcity"));
                                                        $("#bill-show-ConsigneeName").empty();
                                                        $("#bill-show-ConsigneeName").append(showBillOp.attr("consigneename"));
                                                        $("#bill-show-ConsigneeCity").empty();
                                                        $("#bill-show-ConsigneeCity").append(showBillOp.attr("consigneecity"));
                                                        $("#bill-show-Weight").empty();
                                                        $("#bill-show-Weight").append(showBillOp.attr("weight")).append("KG");
                                                        $("#bill-show-Amount").empty();
                                                        $("#bill-show-Amount").append(showBillOp.attr("amount"));
                                                        $("#bill-show-Freight").empty();
                                                        $("#bill-show-Freight").append(showBillOp.attr("freight")).append("$");
                                                        $("#bill-show-PayWay").empty();
                                                        if (showBillOp.attr("payway") === "0")
                                                            $("#bill-show-PayWay").append("Online");
                                                        else {
                                                            $("#bill-show-PayWay").append("Pay On Delivery");
                                                        }
                                                        $("#bill-show-Insurance").empty();
                                                        $("#bill-show-Insurance").append(showBillOp.attr("insured"));
                                                        $("#bill-show-CreateTime").empty();
                                                        $("#bill-show-CreateTime").append(timestampToDatetime(showBillOp.attr("billcreatetime")));
                                                        $("#bill-show-UpdateTime").empty();
                                                        $("#bill-show-UpdateTime").append(timestampToDatetime(showBillOp.attr("billupdatetime")));
                                                        $("#bill-show-Commits").empty();
                                                        $("#bill-show-Commits").append(showBillOp.attr("commit"));
                                                    });
                                                    showBillOp.edbox();
                                                    //修改bill信息模态框
                                                    var changeBillOp = $("<a href='#' title='Edit' edbox data-box-target='#bill-edit-box' billID='" + this.id + "' consignorname='" + this.consignorInfo.name + "' consignorcity='" + this.consignorInfo.mapTown.mapDistrict.mapCity.name
                                                            + "' consigneename='" + this.consigneeInfo.name + "' consigneecity='" + this.consigneeInfo.mapTown.mapDistrict.mapCity.name + "' freight='" + this.freight + "' insured='" + this.insured + "' payway='" + this.panment
                                                            + "' weight='" + this.weight + "' commit='" + this.commit + "' amount='" + this.amount + "' billcreatetime='" + this.createtime + "' billupdatetime='" + this.updatetime + "' status='" + this.status + "' ></a>")
                                                            .append("<i class='fa fa-pencil' aria-hidden='true'></i>");

                                                    changeBillOp.click(function () {
                                                        $("#bill-change-BillID").empty();
                                                        $("#bill-change-BillID").append(changeBillOp.attr("billID"));
                                                        $("#bill-change-ConsignorName").empty();
                                                        $("#bill-change-ConsignorName").val(changeBillOp.attr("consignorname"));
                                                        $("#bill-change-ConsignorCity").empty();
                                                        $("#bill-change-ConsignorCity").val(changeBillOp.attr("consignorcity"));
                                                        $("#bill-change-ConsigneeName").empty();
                                                        $("#bill-change-ConsigneeName").val(changeBillOp.attr("consigneename"));
                                                        $("#bill-change-ConsigneeCity").empty();
                                                        $("#bill-change-ConsigneeCity").val(changeBillOp.attr("consigneecity"));
                                                        $("#bill-change-Weight").empty();
                                                        $("#bill-change-Weight").val(changeBillOp.attr("weight"));
                                                        $("#bill-change-Amount").empty();
                                                        $("#bill-change-Amount").val(changeBillOp.attr("amount"));
                                                        $("#bill-change-Freight").empty();
                                                        $("#bill-change-Freight").val(changeBillOp.attr("freight"));
                                                        $("#bill-change-PayWay").empty();
                                                        if (changeBillOp.attr("payway") === "0")
                                                            $("#bill-change-PayWay").append("Online");
                                                        else {
                                                            $("#bill-change-PayWay").append("Pay On Delivery");
                                                        }
                                                        $("#bill-change-Insurance").empty();
                                                        $("#bill-change-Insurance").val(changeBillOp.attr("insured"));
                                                        var status = "NewBill";
                                                        if (changeBillOp.attr("status") === "2") {
                                                            status = "NewBill";
                                                        }
                                                        if (changeBillOp.attr("status") === "3") {
                                                            status = "ChangedBill";
                                                        }
                                                        $("#bill-change-Stuatus").empty();
                                                        $("#bill-change-Stuatus").append(status);
                                                        $("#bill-change-CreateTime").empty();
                                                        $("#bill-change-CreateTime").append(timestampToDatetime(changeBillOp.attr("billcreatetime")));
                                                        $("#bill-change-UpdateTime").empty();
                                                        $("#bill-change-UpdateTime").append(timestampToDatetime(changeBillOp.attr("billupdatetime")));
                                                        $("#bill-change-Commits").empty();
                                                        $("#bill-change-Commits").append(changeBillOp.attr("commit"));

                                                    });
                                                    changeBillOp.edbox();

                                                    var deleteBill = $("<a href='#' title='Delete' edbox data-box-target='#bill-delete-box' billID='" + this.id + "'></a>")
                                                            .append("<i class='fa fa-trash' aria-hidden='true'></i>");
                                                    deleteBill.click(function () {
                                                        $("#bill-delete-BillID").empty();
                                                        $("#bill-delete-BillID").append(deleteBill.attr("billID"));
                                                    });
                                                    deleteBill.edbox();

                                                    var billOp = $("<td>").append(showBillOp).append("&nbsp;&nbsp;&nbsp;").append(changeBillOp).append("&nbsp;&nbsp;&nbsp;").append(deleteBill).append("&nbsp;&nbsp;&nbsp;");
                                                    //                                            列表身体赋值
                                                    var billRow = $("<tr>").append(billCheckbox).append(consignor)
                                                            .append(consignor_city).append(consignee).append(consignee_city).append(billcreatetime).append(billupdatetime).append(billOp);
                                                    if (rowNum % 2 === 0)
                                                        billRow.addClass("td-bk");
                                                    $("#bill-table-body").append(billRow);
                                                });
                                            }

                                            //删除Bill
                                            function deleteBill() {
                                                $.ajax({
                                                    url: "${pageContext.request.contextPath}/express/deleteoneBill.do",
                                                    data: {
                                                        "billID": $("#bill-delete-BillID").text()
                                                    },
                                                    type: "POST",
                                                    dataType: "json",
                                                    success: function (result) {
                                                        if (result.status === 1) {
                                                            alert("Delete sucess");
                                                            $.edbox('close');
                                                            search_bills();
                                                            getEmployeeAuthen();
                                                        } else {
                                                            alert(result.msg);
                                                        }
                                                    },
                                                    error: function () {
//                                                                alert("Got failed");
                                                    }
                                                });

                                            }
                                            //异步获取数据，获取省信息
                                            function list_bills_selector_province() {
                                                $.ajax({
                                                    url: "${pageContext.request.contextPath}/express/list_working_bills_selector_province.do",
                                                    type: "POST",
                                                    dataType: "json",
                                                    success: function (result) {
                                                        if (result.status === 1) {
                                                            init_province_select(result.data);
                                                        } else {

                                                        }
                                                    },
                                                    error: function () {
//                                                                alert("Got failed");
                                                    }
                                                });
                                            }
                                            //省的选择器初始化
                                            function init_province_select(prodata) {
                                                $('#selectStartPageProvince').selectPage({
                                                    showField: 'name',
                                                    keyField: 'id',
                                                    data: prodata, //给选择器赋值
                                                    eSelect: function (data) {
                                                        if (data) {
                                                            var proid = data.id;
                                                            $.ajax({
                                                                url: "${pageContext.request.contextPath}/express/list_working_bills_selector_city.do",
                                                                type: "POST",
                                                                dataType: "json",
                                                                data: {
                                                                    "selectprovince": proid
                                                                },
                                                                success: function (result) {
                                                                    if (result.status === 1) {
                                                                        var resultdata = result.data;
                                                                        $('#selectStartPageCity').selectPageData(resultdata);
                                                                    } else {
                                                                        alert(result.msg);
                                                                    }
                                                                },
                                                                error: function () {
//                                                                            alert("Got failed");
                                                                }
                                                            });
                                                            //selectPageData()就是为组件加数据，这里的数据单元必须是一个完整的数据项
                                                        }
                                                    },
                                                    eClear: function () {//清空时，同时清空城市内容
                                                        $('#selectStartPageCity').selectPageClear();
                                                        $('#selectStartPageCity').selectPageData([]);
                                                    }
                                                });

                                                //初始End省份选择器初始化
                                                $('#selectEndPageProvince').selectPage({
                                                    showField: 'name',
                                                    keyField: 'id',
                                                    data: prodata,
                                                    eSelect: function (data) {
                                                        if (data) {
                                                            var proid = data.id;
                                                            $.ajax({//因为异步请求会再次开一个线程去获取，如果不嵌套的话赋值就附不上
                                                                url: "${pageContext.request.contextPath}/express/list_working_bills_selector_city.do",
                                                                type: "POST",
                                                                dataType: "json",
                                                                data: {
                                                                    "selectprovince": proid
                                                                },
                                                                success: function (result) {
                                                                    if (result.status === 1) {
                                                                        var resultdata = result.data;
                                                                        $('#selectEndPageCity').selectPageData(resultdata);
                                                                    } else {
                                                                        alert(result.msg);
                                                                    }
                                                                },
                                                                error: function () {
//                                                                            alert("Got failed");
                                                                }
                                                            });
                                                            //selectPageData()就是为组件加数据，这里的数据单元必须是一个完整的数据项
                                                        }
                                                    },
                                                    eClear: function () {//清空时，同时清空城市内容
                                                        $('#selectEndPageCity').selectPageClear();
                                                        $('#selectEndPageCity').selectPageData([]);
                                                    }
                                                });
                                            }

                                            function init_city() {//初始化city的组件
                                                //City初始化
                                                $('#selectStartPageCity').selectPage({
                                                    showField: 'name',
                                                    keyField: 'id',
                                                    data: []
                                                });
                                                //City初始化
                                                $('#selectEndPageCity').selectPage({
                                                    showField: 'name',
                                                    keyField: 'id',
                                                    data: []
                                                });
                                                var status = [
                                                    {id: '001', status: 'New Work Bill'},
                                                    {id: '002', status: 'Updated Bill'},
                                                    {id: '003', status: 'Finished Bill'}
                                                ];
                                                //状态选择初始化
                                                $('#selectPageStatus').selectPage({
                                                    showField: 'status',
                                                    keyField: 'id',
                                                    data: status
                                                });
                                            }
                                            function editNewBill() {
                                                $.ajax({
                                                    url: "${pageContext.request.contextPath}/express/update_bill_info.do",
                                                    data: {
                                                        "billID": $("#bill-change-BillID").text(),
                                                        "weight": $("#bill-change-Weight").val(),
                                                        "amount": $("#bill-change-Amount").val(),
                                                        "freight": $("#bill-change-Freight").val(),
                                                        "insurance": $("#bill-change-Insurance").val(),
                                                        "consignorname": $("#bill-change-ConsignorName").val(),
                                                        "consignorcity": $("#bill-change-ConsignorCity").val(),
                                                        "consigneename": $("#bill-change-ConsigneeName").val(),
                                                        "consigneecity": $("#bill-change-ConsigneeCity").val()
                                                    },
                                                    type: "POST",
                                                    dataType: "json",
                                                    success: function (result) {
                                                        if (result.status === 1) {
                                                            $.edbox({success: result.msg});
                                                            $.edbox('close');
                                                            search_bills();
                                                        } else {
                                                            $.edbox({danger: result.msg});
                                                        }
                                                    },
                                                    error: function () {
                                                        $.edbox({danger: 'Update failed!'});
                                                    }
                                                });
                                            }
                                            function passbill() {//用于快递员把订单完成的方法
                                                $.ajax({
                                                    url: "${pageContext.request.contextPath}/express/finishedBill.do",
                                                    data: {
                                                        "billinfoID": $("#bill-show-BillID").text()
                                                                //向后端传值的时候，如果是input就是value，如果是别的组件里的值，一般用text
                                                    },
                                                    type: "POST",
                                                    dataType: "json",
                                                    success: function (result) {
                                                        if (result.status === 1) {
                                                            $.edbox({success: result.msg});
                                                            $.edbox('close');
                                                            search_bills();
                                                        } else {
                                                            $.edbox({danger: result.msg});
                                                        }
                                                    },
                                                    error: function () {
//                                                                    $.edbox({danger: "Got failed!"});
                                                    }
                                                });

                                            }


        </script>

    </body>
</html>
